// ignore_for_file: must_be_immutable

import 'package:flutter/material.dart';
import 'package:junyeyishu/utils/ScreenFit.dart';

class QGButton extends StatelessWidget {
  String title;
  bool enable;

  void Function()? onTap;
  QGButton({
    super.key,
    required this.title,
    this.enable = true,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        if (enable && onTap != null) {
          onTap!();
        }
      },
      child: Container(
        alignment: Alignment.center,
        height: 44.rpx,
        decoration: bgColor(),
        child: Text(
          title,
          style: TextStyle(
              color: textColor(),
              fontSize: 14.rpx,
              fontWeight: FontWeight.normal),
        ),
      ),
    );
  }

  textColor() {
    return enable ? Color(0xFF111111) : Color(0xFF999999);
  }

  bgColor() {
    if (enable) {
      return BoxDecoration(
        gradient: const LinearGradient(
          begin: Alignment.centerLeft,
          end: Alignment.centerRight,
          colors: [Color(0xFF4AE3FF), Color(0xFF44FFF0)],
        ),
        borderRadius: BorderRadius.circular(30.rpx),
      );
    } else {
      return BoxDecoration(
          borderRadius: BorderRadius.circular(30.rpx),
          color: Color(0xFFCCCCCC));
    }
  }

  outBgColor() {
    if (enable) {
      return BoxDecoration(
          borderRadius: BorderRadius.circular(19.rpx),
        
         );
    } else {
      return BoxDecoration(
          borderRadius: BorderRadius.circular(19.rpx),
          color: const Color(0xFFCCCCCC));
    }
  }
}

class QGOutlineButton extends QGButton {
  QGOutlineButton(
      {super.key,
      required super.title,
      required super.enable,
      required super.onTap});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        alignment: Alignment.center,
        height: 44.rpx,
        decoration: outBgColor(),
        child: Text(
          title,
          style: TextStyle(
              color: const Color(0xffFFFFFF),
              fontSize: 14.rpx,
              fontWeight: FontWeight.normal),
        ),
      ),
    );
  }
}
